import threading

value = 0
lock = threading.Lock()  # 创建锁示例


def add_value():
    global value
    lock.acquire()  # 获得锁
    for x in range(10000000):
        value += 1
    lock.release()  # 释放锁
    print('value:', value)


def main():
    threads = []
    for i in range(0, 2):
        t = threading.Thread(target=add_value)
        threads.append(t)

    for i in range(0, 2):
        threads[i].start()


if __name__ == '__main__':
    main()
